number_hunters_ratio = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
i = 0
treshold = 10
glob_n_players = 0

# The strategy is to "steal" food by slacking when my reputation is high.

# I slack a lot when my reputation is high and when my reputation is low I 
# hunt more in order to gain reputation

# I divide all reputations into quartiles and take different actions depending 
# on in which quartile I am currently located

# I also calculate what a low m is by collecting information about the number 
# of hunters each round. When m is low I hunt a bit more

def hunt_choices(round_number, current_food, current_reputation, m, player_reputations):
    global number_hunters_ratio, i, treshold, glob_n_players
    hunt_decisions = []
    n_players = len(player_reputations)
    glob_n_players = n_players

    mean = float(sum(player_reputations)) / n_players
    first_q = sorted(player_reputations)[n_players * 1/4]
    median = sorted(player_reputations)[n_players * 1/2]
    third_q = sorted(player_reputations)[n_players * 3/4]

    big_chance_for_bonus =  m < n_players * sum(number_hunters_ratio) / ((i % treshold) + 1)
    
    if current_reputation < first_q:
        if big_chance_for_bonus:
             for reputation in player_reputations:
                 hunt_decisions.append('h')
        else:
            for reputation in player_reputations:
                hunt_decisions.append('h' if reputation >= first_q else 's')
    elif current_reputation < median:
        if big_chance_for_bonus:
            for reputation in player_reputations:
                hunt_decisions.append('h' if reputation <= third_q or reputation >= first_q  else 's')
        else:
            for reputation in player_reputations:
                hunt_decisions.append('h' if reputation >= first_q else 's')

    elif current_reputation >= third_q:
        for reputation in player_reputations:
            hunt_decisions.append('s')
    else:
        if big_chance_for_bonus:
            for reputation in player_reputations:
                hunt_decisions.append('s' if reputation >= third_q or reputation <= first_q else 'h')
        else:
            for reputation in player_reputations:
                hunt_decisions.append('s')
    return hunt_decisions

def hunt_outcomes(food_earnings):
    pass

def round_end(award, m, number_hunters):
    global number_hunters_ratio, i, treshold, glob_n_players
    number_hunters_ratio[i % treshold] = number_hunters / glob_n_players 
    i += 1
